#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif

using namespace std;

void sleep_seconds(int sec) {
    #ifdef _WIN32
        Sleep(sec * 1000);
        #else
            sleep(sec);
            #endif
}

int main() {
        srand(time(0));
            string responses[] = {
                        "服务器繁忙，请稍后再试。",
                                "系统正在维护中...",
                                        "网络连接不可用，请检查配置。",
                                                "请求超时，请重试。",
                                                        "服务暂时不可用。",
                                                                "资源不足，无法处理请求。",
                                                                        "正在排队处理中...",
                                                                                "数据库连接失败。",
                                                                                        "API速率限制已触发。",
                                                                                                "云服务提供商出现故障。"
            };

                cout << "BusyAI已启动（输入quit退出）" << endl;
                    
                        while(true) {
                                    string input;
                                            cout << "\n用户输入: ";
                                                    getline(cin, input);
                                                            
                                                                    if(input == "quit") break;
                                                                            
                                                                                    int index = rand() % 10;
                                                                                            cout << "BusyAI: " << responses[index] << endl;
                                                                                                    
                                                                                                            // 模拟延迟
                                                                                                                    for(int i = 0; i < 3; i++) {
                                                                                                                                    cout << "." << flush;
                                                                                                                                                sleep_seconds(1);
                                                                                                                    }
                                                                                                                            cout << endl;
                        }
                            return 0;
}
                                                                                                                    }
                        }
            }
}
}